home *** CD-ROM | disk | FTP | other *** search
/ Pirate Informatique 34 / Pirate infomatique No34.iso / js / pages.js < prev    next >
Text File  |  2011-09-16  |  3KB  |  82 lines

  1. $(window).load(function() {    
  2.     var act='';
  3.     
  4.     $('#content > ul > li').css({position:'absolute', display:'none'});
  5.     $('#content > ul > li').find('.box1').css({height:'0'})
  6.     
  7.     $('#menu > li > a span').css({opacity:'0'})
  8.     
  9.     $('#menu > li > a').hover(function(){
  10.         $(this).find(' > span').stop().animate({opacity:'1'},600);                           
  11.     }, function(){
  12.         if (!$(this).hasClass('active')) {
  13.             $(this).find(' > span').stop().animate({opacity:'0'},600);                           
  14.         }
  15.     })
  16.     
  17.     $('#menu > li').each(function(num){
  18.         $(this).data({num:num})
  19.     })
  20.     $('#content > ul > li').each(function(num){
  21.         $(this).data({num:num})
  22.     })
  23.     
  24.     if (location.hash.slice(0,3)=='#!/') {
  25.         page=location.hash.slice(3);
  26.         open_page('#'+page);
  27.         fl=false;
  28.     }
  29.     if ((location.hash=='#')||(location.hash=='')) {
  30.         open_page('');
  31.         fl=true;
  32.             $('#content').stop().animate({height:'668'})
  33.     }
  34.     $('a').click(function(){
  35.         if ($(this).attr('href').slice(0,3)=='#!/') {
  36.             page=$(this).attr('href').slice(3);    
  37.             open_page('#'+page);
  38.             return false;
  39.         }
  40.         if ($(this).attr('data-type')=='close') {
  41.             close_page()    
  42.         }
  43.     })
  44.     function open_page(page){
  45.         location.hash='#!/'+page.slice(1);
  46.         $('#menu a').removeClass('active').find(' > span').stop().animate({opacity:'0'},600);
  47.         Cufon.replace('#menu a', { fontFamily: 'Ubuntu', hover:true });
  48.         num=$(page).data('num');
  49.         $('#menu > li').each(function(){                      
  50.             if ($(this).data('num')==num) {
  51.                 $(this).find('> a').addClass('active').find('> span').stop().animate({opacity:'1'},600);
  52.                 Cufon.replace('#menu a', { fontFamily: 'Ubuntu', hover:true });
  53.             }
  54.         })
  55.         fl=false;
  56.         $('#content').stop().animate({height:'868'})
  57.         if (act!='') {
  58.             $(act).find('.box1').stop().animate({height:'0'},700,'easeOutCirc', function(){
  59.                 $(act).css({display:'none'});
  60.                 $(page).css({display:'block'}).find('.box1').stop().animate({height:'100%'},700, 'easeOutCirc', function(){
  61.                     act=page;    
  62.                 });    
  63.             })
  64.         } else {
  65.             $(page).css({display:'block'}).find('.box1').stop().animate({height:'100%'},700, 'easeOutCirc', function(){
  66.                 act=page;    
  67.             });        
  68.         }
  69.     }
  70.     function close_page(page){
  71.         $('#menu a').removeClass('active').find(' > span').stop().animate({opacity:'0'},600);
  72.         Cufon.replace('#menu a', { fontFamily: 'Ubuntu', hover:true });
  73.         location.hash='#';
  74.         $(act).find('.box1').stop().animate({height:'0'},700,'easeOutCirc', function(){
  75.             $(act).css({display:'none'});
  76.             act='';
  77.             fl=true;
  78.             $('#content').stop().animate({height:'668'})
  79.         });    
  80.         return false;
  81.     }
  82. })